/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import java.util.Hashtable;

import javax.naming.InitialContext;

import entities.vo.ArticuloVO;
import fachada.Fachada;

/**
 *
 * @author Jhonny
 */
public abstract class Model {
	//private static final String naming = "TiendaZARAServidor/FachadaBean/remote";
	
	protected Fachada 			fachada;
	private InitialContext 		initialContext;
	
	public Model() {
		inicializarContexto();
	}
	/**
	 * Se indica url del servidor de aplicaciones
	 *
	 */
	private void inicializarContexto() {
		try{
			String naming = "TiendaZARAServidorEAR/FachadaBean/remote";
			Hashtable<String, String> props = new Hashtable<String, String>();
			props.put(InitialContext.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
			//Url completa de ubicacion del servidor de aplicaciones
			props.put(InitialContext.PROVIDER_URL,"jnp://localhost:1099");
			//props.put(InitialContext.PROVIDER_URL,"jnp://172.16.171.116:1099");
			//Objeto del tipo InitialContext
			initialContext = new InitialContext(props);
			fachada = (Fachada) initialContext.lookup(naming);
		}catch(Exception ex){
			System.out.println(ex.getMessage());
			ex.printStackTrace();
		}
	}
    public ArticuloVO getArticulo(Integer referencia){
        ArticuloVO articulo = null;
        articulo = fachada.getArticulo(referencia);
        return articulo;
    }

}
